<?php defined('SYSPATH') or die('No direct script access.');
 
class Model_Aphoto extends ORM {
	protected $_table_name = 'photo';

    public function params() {
        return array(
        	'model' => 'Aphoto',
            'view' => 'apieces/abase/aphotoList',
            'table' => 'photo',
            'fields' => array(
                'category_id' => array(
                    'title' => 'Категория',
                    'name' => 'category_id',
                    'type' => 'relation',
                    'relation_params' => array(
                        'type' => 'BELONGS_TO',
                        'model' => 'Aphotocat',
                        'field' => 'title'
                    ),
                ),
                'description' => array(
                    'title' => 'Описание',
                    'type' => 'textarea',
                    'name' => 'description',
                ),
                'image' => array(
                    'title' => 'Изображение',
                    'type' => 'image',
                    'name' => 'image',
                    'image_params' => array(
                        'width' => 1600,
                        'height' => null,
                        'handling' => 'resize',
                        'resize_type' => Image::WIDTH,
                        'dir' => $_SERVER['DOCUMENT_ROOT'].'/static/uploads/photo',
                        'url' => URL::base().'static/uploads/photo',
                    ),
                    'thumbnails' => array(
                        'small' => array(
                            'width' => 210,
                            'height' => 160,
                            'handling' => 'resize_crop',
                            'resize_type' => Image::AUTO,
                        ),
                        'admin' => array(
                            'width' => 300,
                            'height' => 200,
                            'handling' => 'resize_crop',
                            'resize_type' => Image::AUTO,
                        ),
                    ),
                ),
                'display' => array(
                    'title' => 'Показывать?',
                    'type' => 'checkbox',
                    'name' => 'display',
                ),
            ),
            'search_indexes' => array(
                array('field' => 'description', 'title' => 'Описание'),
            ),
            'main_title' => 'Фото',
            'waymark' => 'description',
            'admin_image_url' => URL::base().'static/uploads/photo/admin',
            'admin_image_field' => 'image',
            'sortable' => TRUE
        );
    }

}